/**
 * Created by Francis.LW on 2017/10/20.
 *
 * 数据字典服务接口
 */
import {basePostRequest, postRequest, getRequest} from '@/common/request'
import {urls} from './url'

const dictionaryApi = urls.dictionary

function listAll(param, success, complete) {
  postRequest(dictionaryApi.listAll, {}, param, success, complete)
}

function listAllDictory(pid, success, complete) {
  getRequest(dictionaryApi.listAllDictory + pid, {}, success, complete)
}

function listDictory(param, page, pageSize, success, complete) {
  postRequest(dictionaryApi.listDictory + '?currentpage=' + page + '&pagesize=' + pageSize, {}, param, success, complete)
}

function saveDictory(param, success, complete) {
  postRequest(dictionaryApi.saveDictory, {}, param, success, complete)
}

function updateDictory(id, param, success, complete) {
  postRequest(dictionaryApi.updateDictory + id, {}, param, success, complete)
}

function getDictory(id, success, complete) {
  getRequest(dictionaryApi.getDictory + id, {}, success, complete)
}

function removeDictory(ids, success, complete) {
  postRequest(dictionaryApi.removeDictory, {}, ids, success, complete)
}

/**
 *
 * @param ids
 * @param success
 * @param complete
 */
function deleteSingleDictory(id, success, complete) {
  let ids = []
  ids.push(id)
  removeDictory(ids, success, complete)
}

export default {
  listAll,
  listAllDictory,
  listDictory,
  saveDictory,
  updateDictory,
  getDictory,
  removeDictory,
  deleteSingleDictory
}
